package star.反转链表;

public class ReverseList {
    public static void main(String[] args) {

    }
    public ListNode reverseList(ListNode head){
        if (head==null) return null;
        ListNode result = null;
        ListNode temp = head;
        while (head!=null) {
            temp = head;
            head = head.next;
            temp.next = result;
            result = temp;
        }
        return result;
    }
}
